<!--
current-time
时间
-->
<template>
    <div class="current-time">{{ currentTime }}</div>
</template>

<script>

export default {
    name: 'current-time',
    data() {
        return {
            timer: null,
            currentTime: new Date(),
        };
    },
    created() {
        const that = this;
        this.timer = setInterval(() => {
            that.currentTime = `${new Date().getFullYear()}
            .${new Date().getMonth() + 1}
            .${new Date().getDate()} ${new Date().getHours()}
            :${new Date().getMinutes()}
            : ${new Date().getSeconds()}`;
        }, 1000);
    },
    beforeDestroy() {
        if (this.timer) {
            clearInterval(this.timer);
        }
    },
};
</script>
<style lang='scss' scoped>

</style>
